package com.qianyitian.hope2.analyzer.controller;

import com.qianyitian.hope2.analyzer.service.GradeScoreService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.web.bind.annotation.*;

@RestController
public class GradeScoreController {
    private Logger logger = LoggerFactory.getLogger(getClass());


    @Autowired
    GradeScoreService gradeScoreService;

    public GradeScoreController() {
    }

    @Async
    @RequestMapping(value = "/grade/refresh", method = RequestMethod.GET)
    @Scheduled(cron = "0 0 4 * * MON,TUE,WED,THU,FRI,SAT")
    public void startGradingScore() {
        gradeScoreService.grade();
    }

    @GetMapping(value = "/grade/stock")
    public String loadStockGrade() {
        return gradeScoreService.getAllStockGrade();
    }

    @GetMapping(value = "/grade/stock_lite")
    public String loadStockGradeLite() {
        return gradeScoreService.getAllStockGradeLite();
    }

}
